<?php

abstract class Service_DataSource
{
    protected $_options = array();
    
    protected $_conditionPrefix = 'Service_Condition';

    protected $_name = '';

    public function  __construct($options, $name = '')
    {
        $this->_options = $options;
        $this->_name = $name;
    }

    public function getName()
    {
        return $this->_name;
    }

    public function setName($name)
    {
        $this->_name = $name;
    }

    public function createCondition($name, $params = array())
    {
        if ($this->_conditionPrefix) {
            $className = $this->_conditionPrefix . '_' . $name;
        } else {
            $className = '';
        }

        if (Zend_Loader::loadClass($className)) {
            require_once 'Service/DataSource/ConditionClassNotFoundException.php';
            throw new Service_DataSource_ConditionClassNotFoundException(
                    "Condition class '$className' not found.");
        }

        $cond = new $className($params);

        $cond->setDataSource($this);

        return $cond;
    }

    public function getItem($spec, $id, $attrList = null)
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }

    public function removeItem($spec, $id)
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }
    
    public function removeItems($spec, $filters = array())
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }

    public function putItem($spec, $id, $item)
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }
    
    public function updateItems($spec, $fields, $filters = array())
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }

    public function listItems($spec, $attrList = null, $limit = null,
        $offset = 0, $sort = array(), $filters = array())
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }
    
    public function countItems($spec, $filters = array())
    {
        require_once 'Service/MethodNotImplementedException.php';
        throw new Service_MethodNotImplementedException();
    }
}
